import uuid
from typing import Optional

from fastapi_users import schemas
from pydantic import BaseModel, UUID4
from datetime import datetime


class UserRead(schemas.BaseUser[uuid.UUID]):
    username: str
    phone: Optional[str] = None
    email: Optional[str] = None
    nickname: Optional[str] = None
    avatar: Optional[str] = None
    gender: Optional[int] = None
    birthday: Optional[datetime] = None
    department: Optional[str] = None
    position: Optional[str] = None
    status: Optional[int] = None

    class Config:
        orm_mode = True


class UserCreate(schemas.BaseUserCreate):
    username: str
    phone: Optional[str] = None
    email: Optional[str] = None
    nickname: Optional[str] = None
    avatar: Optional[str] = None
    gender: Optional[int] = None
    birthday: Optional[datetime] = None
    department: Optional[str] = None
    position: Optional[str] = None
    status: Optional[int] = None
    is_active: Optional[bool] = True
    is_verified: Optional[bool] = True
    is_superuser: Optional[bool] = False


class UserUpdate(schemas.BaseUserUpdate):
    pass


class UserSessionRead(BaseModel):
    id: UUID4
    user_id: str
    file_name: str
    upload_time: datetime
    session_title: str
    analysis_status: Optional[str]
    session_remark: str
    dataset_ids: Optional[str] = ""

    class Config:
        orm_mode = True


class UserMsgRead(BaseModel):
    id: UUID4
    user_id: str
    session_id: str
    message: str
    message_type: str
    message_model: Optional[str]
    message_intent: Optional[str]
    message_confirm: Optional[str]
    message_suggest: Optional[str]
    timestamp: datetime

    class Config:
        orm_mode = True
